package proxy.cglib;

import com.ww.microrpc.netty.handler.client.SendCallback;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

public class CglibProxy implements MethodInterceptor {
    @Override
    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
        for (int i = 0; i < objects.length; i++) {
            System.out.println(objects.getClass());
            Object arg = objects[i];
            if (arg instanceof SendCallback) {
                SendCallback sendCallback = (SendCallback) arg;
                sendCallback.onSuccess("success");
                System.out.println(sendCallback.getClass());
            }
        }
        return null;
    }
}
